import {
  createApp
} from 'vue'
import {
  ActionBar,
  ActionBarIcon,
  ActionBarButton,
  Divider,
  Popup,
  Overlay,
  Loading,
  Dialog,
  ContactCard,
  Form,
  AddressEdit,
  AddressList,
  Field,
  CellGroup,
  Cell,
  SwipeCell,
  Icon,
  Stepper,
  Card,
  Checkbox,
  CheckboxGroup,
  Button,
  Swipe,
  SwipeItem,
  PullRefresh,
  List,
  Tab,
  Tabs,
  SubmitBar,
  Toast,
  Skeleton,
  Image,
  Uploader,
  RadioGroup,
  Radio,
  Picker,
  Area,
  Cascader,
  Search,
  Step,
  Steps,
  DropdownMenu,
  DropdownItem,
  ImagePreview,
  Tag,
  Collapse,
  CollapseItem,
  NavBar,
  Calendar,
  Col,
  Row,
} from 'vant'
import App from './App.vue'
import store from './store'
import router from './router'
import 'lib-flexible/flexible'
import 'vant/lib/index.css'; // 全局引入样式
import localStorage from "./utils/localStorage.js";
import sessionStorage from "./utils/sessionStorage.js";
import verify from "./utils/verify.js";
import {
  getTabList,
  conver,
  listAssign
} from "./utils/data.js";

import CustomSelect from '@/components/CustomSelect.vue'

const app = createApp(App) // 创建实例

// 全局过滤器
app.config.globalProperties.$filters = {
  prefix(url) {
    if (url && url.startsWith('http')) {
      return url
    } else {
      url = `http://backend-api-01.newbee.ltd${url}`
      return url
    }
  }
}
//获取屏幕高度
// app.config.globalProperties.$getViewportSize = function() {
//   return {
//     width:window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
//     height:window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
//   };
// };

app.config.globalProperties.$sessionStorage = sessionStorage
app.config.globalProperties.$localStorage = localStorage
app.config.globalProperties.$verify = verify
app.config.globalProperties.getTabList = getTabList
app.config.globalProperties.converSize = conver
app.config.globalProperties.listAssign = listAssign

app.use(ActionBarButton)
  .use(ActionBarIcon)
  .use(ActionBar)
  .use(Divider)
  .use(Popup)
  .use(Overlay)
  .use(Loading)
  .use(Dialog)
  .use(Toast)
  .use(ContactCard)
  .use(Form)
  .use(AddressEdit)
  .use(AddressList)
  .use(Field)
  .use(CellGroup)
  .use(Cell)
  .use(Image)
  .use(SwipeCell)
  .use(Icon)
  .use(Stepper)
  .use(Card)
  .use(Button)
  .use(Swipe)
  .use(SwipeItem)
  .use(PullRefresh)
  .use(List)
  .use(Tab)
  .use(Tabs)
  .use(SubmitBar)
  .use(Checkbox)
  .use(CheckboxGroup)
  .use(Skeleton)
  .use(Uploader)
  .use(RadioGroup)
  .use(Radio)
  .use(Picker)
  .use(Area)
  .use(Cascader)
  .use(Search)
  .use(Step)
  .use(Steps)
  .use(DropdownMenu)
  .use(DropdownItem)
  .use(ImagePreview)
  .use(Tag)
  .use(Collapse)
  .use(CollapseItem)
  .use(NavBar)
  .use(Calendar)
  .use(Col)
  .use(Row)
app.use(router)
app.use(store)
app.component('CustomSelect', CustomSelect)
// app.component('ImagePreview', ImagePreview)
// [ImagePreview.Component.name]: ImagePreview.Component,

app.mount('#app')